<template>
  <button class="invite-btn" @click="handleInvite">
    <image src="/static/plus.png" class="icon"></image>
    邀请好友
  </button>
</template>

<script>
export default {
  methods: {
    async handleInvite() {
      try {
        const res = await uni.share({
          provider: 'weixin',
          scene: 'WXSceneSession',
          type: 0,
          title: '加入我的弹珠游戏！',
          summary: '快来和我一起玩童年弹射-弹珠擂台吧！',
          href: 'https://your-game-link.com'
        })
        
        if (res.errMsg === 'share:ok') {
          uni.showToast({
            title: '邀请成功',
            icon: 'success'
          })
          this.$emit('invite-success')
        }
      } catch (error) {
        uni.showToast({
          title: '邀请失败',
          icon: 'none'
        })
      }
    }
  }
}
</script>

<style>
.invite-btn {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background-color: #4CAF50;
  color: white;
  border-radius: 20px;
  border: none;
  font-size: 14px;
}

.icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}
</style>
